import { Router } from 'vue-router'
import { mainInfo } from '../view/admin'
import { roomInfo, addRoom,hotelInfo, addHotel, updateRoom, indentInfo, commentInfo, countInfo } from '../view/user'
import  updatePassword  from '../view/updatePassword.vue'

export const user = [
    { title:'客房管理', icon:'Notification', meta: 'main/room', list:[] },
    { title:'酒店管理', icon:'ShoppingCartFull', meta: 'main/hotel', list:[] },
    { title:'订单管理', icon:'Edit', meta: 'main/indent', list:[] },
    { title:'售后管理', icon:'MessageBox', meta: 'main/postSale', list:[] },
    { title:'统计管理', icon:'Orange', meta: 'main/count', list:[] }
]
type updateRoom = {
    roomId: number
    hotel_id: number
}
const userRouter = [
    {
        path:'/main/user/mainInfo',
        name:'mainInfo',
        component: mainInfo
    },
    {
        path:'/main/addHotel',
        name:'addHotel',
        component: addHotel
    },
    {
        path:'/main/updateRoom',
        name:'updateRoom',
        component: updateRoom,
        props: (route: { query:updateRoom }) => ({
            roomId: route.query.roomId,
            hotel_id: route.query.hotel_id,
        })
    },
    {
        path:'/main/room/roomInfo',
        name:'roomInfo',
        component: roomInfo
    },
    {
        path:'/main/room/addRoom',
        name:'addRoom',
        component: addRoom
    },
    {
        path:'/main/hotel/hotelInfo',
        name:'hotelInfo',
        component: hotelInfo
    },
    {
        path:'/main/indent/indentInfo',
        name:'indentInfo',
        component: indentInfo
    },
    {
        path:'/main/postSale/commentInfo',
        name:'commentInfo',
        component: commentInfo
    },
    {
        path:'/main/updatePassword',
        name:'updatePassword',
        component: updatePassword,
    },
    {
        path:'/main/count/countInfo',
        name:'countInfo',
        component: countInfo,
    }
]

export function addUserRoute(router:Router) {
    userRouter.forEach(el => {
        router.addRoute('main', { path: el.path, name: el.name, component: el.component, props: el?.props })
    })
    router.getRoutes().forEach(el => {
        if (el.name === 'main') {
            el.redirect = '/main/room/roomInfo'
        }
    })
}